package com.elitect.ftptransfer.dialog;

import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.view.ViewGroup.LayoutParams;
import android.widget.ScrollView;
import android.widget.TextView;

import com.elitect.ftptransfer.R;

/**
 * The dialog for show a message that can be updated later.
 * 
 * @author NgocTan
 * 
 */
public class MessageDialog extends Dialog
{
    private TextView mViewContent;
    private Dialog mDialog;

    public MessageDialog(Context context, String title)
    {
        super(context);

        ScrollView scrollView = new ScrollView(context);
        scrollView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
                LayoutParams.WRAP_CONTENT));

        mViewContent = new TextView(context);
        mViewContent.setBackgroundColor(Color.WHITE);
        mViewContent.setPadding(5, 10, 5, 10);
        mViewContent.setLayoutParams(new LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
        mViewContent.setTextColor(Color.BLACK);

        scrollView.addView(mViewContent);

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setIcon(android.R.drawable.ic_dialog_info).setTitle(title).setView(
                scrollView).setPositiveButton(R.string.ok, null);
        mDialog = builder.create();
    }

    @Override
    public void show()
    {
        mDialog.show();
    }

    public void updateMessage(String message)
    {
        mViewContent.setText(message);
    }
}
